package com.generic.util;

import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Properties;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/* Loads the specified property file into a Struts property object for references.
 * This class is NOT intended for retrieving message resources for Struts action 
 * classes. */
public class PropertyUtil {

	private static final Log log = LogFactory.getLog(PropertyUtil.class);
	
	public static Properties getProperty(String fileName) {
		InputStream in = null;
		Properties p = new Properties();
		try {
			in = new FileInputStream(fileName);
			p.load(in);
		} catch(Exception e) {
			log.error(e.getMessage());
		} finally {
			try {
				if(in != null) {
					in.close();
				}				
			} catch(Exception e) {}
		}
		return p;
	}
	
	public static void main(String[] args) {
		Properties p = PropertyUtil.getProperty("../"+Constant.PROPERTIES_MAIL_CONFIG);
		System.out.println(p.getProperty("mail.host"));
	}
}